/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Action;

import Game.NewGame;
import Map.Map;
import Map.MapUtils;
import Player.Inventory;
import Tactics.TackticUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import net.slashie.libjcsi.CharKey;

/**
 *
 * @author insane
 */
public class KeyPressed {

    public static Map getCheckPressed(Map map, int key) throws FileNotFoundException, IOException, ClassNotFoundException {

        switch (key) {

            case CharKey.UARROW:
                map.y--;
                if (MapUtils.checkMove(map.getMap(), map.x, map.y) || TackticUtils.checkMove(map.x, map.y)) {
                    map.y++;
                }
                break;
            case CharKey.DARROW:
                map.y++;
                if (MapUtils.checkMove(map.getMap(), map.x, map.y) || TackticUtils.checkMove(map.x, map.y)) {
                    map.y--;
                }
                break;
            case CharKey.LARROW:
                map.x--;
                if (MapUtils.checkMove(map.getMap(), map.x, map.y) || TackticUtils.checkMove(map.x, map.y)) {
                    map.x++;
                }
                break;
            case CharKey.RARROW:
                map.x++;
                if (MapUtils.checkMove(map.getMap(), map.x, map.y) || TackticUtils.checkMove(map.x, map.y)) {
                    map.x--;
                }
                break;
            case CharKey.o:
                Event.getInstance().openDoor(map.getMap(), map.x, map.y);
                break;

            /*
             * str
             */
            case CharKey.s:
                NewGame.getPlayer().addStr();
                break;
            /*
             * dex
             */
            case CharKey.d:
                NewGame.getPlayer().addDex();
                break;


            /*
             * int
             */
            case CharKey.i:
                NewGame.getPlayer().addInt();
                break;
            /*
             * hlt
             */
            case CharKey.h:
                NewGame.getPlayer().addHlt();
                break;

            case CharKey.N0:
                Inventory.getInstance().drinkPotion(0);
                break;
            case CharKey.N1:
                Inventory.getInstance().drinkPotion(1);
                break;
            case CharKey.N2:
                Inventory.getInstance().drinkPotion(2);
                break;
            case CharKey.N3:
                Inventory.getInstance().drinkPotion(3);
                break;
            case CharKey.N4:
                Inventory.getInstance().drinkPotion(4);
                break;
            case CharKey.N5:
                Inventory.getInstance().drinkPotion(5);
                break;
            case CharKey.N6:
                Inventory.getInstance().drinkPotion(6);
                break;
            case CharKey.N7:
                Inventory.getInstance().drinkPotion(7);
                break;
            case CharKey.N8:
                Inventory.getInstance().drinkPotion(8);
                break;
            case CharKey.N9:
                Inventory.getInstance().drinkPotion(9);
                break;

            case CharKey.Q:
            case CharKey.q:
                return null;

        }
        return map;
    }
}
